package org.dromara.oce.domain.bo;

import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.oce.domain.OceTitleWrap;

import java.io.Serializable;
import java.util.List;

/**
 * 标题包业务对象 oce_title_wrap
 *
 * @author dsbb
 * @date 2025-06-16
 */
@Data
@EqualsAndHashCode()
@AutoMapper(target = OceTitleWrap.class, reverseConvertGenerate = false)
public class OceTitleWrapBo implements Serializable {

    /**
     *
     */
    @NotNull(message = "不能为空", groups = {EditGroup.class})
    private Long id;

    /**
     * 标题包名
     */
    private String name;

    /**
     * 标题集合
     */
    @NotEmpty(message = "标题不能为空")
    @Size(message = "请输入标题")
    private List<String> titles;

    public void checkParam() {
        for (String title : titles) {
            int length = title.length();
            if (length > 55 || length < 5) {
                throw new ServiceException("创意标题，长度为5-55个字, 两个英文字符占1位。");
            }
        }

    }


}
